//
//  DCMarketBaseCell.m
//  Driver
//
//  Created by 大橙子 on 2018/11/8.
//  Copyright © 2018 Tomous. All rights reserved.
//

#import "DCMarketBaseCell.h"

@implementation DCMarketBaseCell
-(void)setUpBaseUI
{
    UIView *firstView = [[UIView alloc]init];
    firstView.backgroundColor = [UIColor whiteColor];
    self.firstView = firstView;
    [self addSubview:firstView];
    
    UIImageView *carrierImage = [[UIImageView alloc]initWithImage:IMAGENAME(@"用户头像")];
    //    carrierImage.backgroundColor = [UIColor redColor];
    self.carrierImage = carrierImage;
    [self.firstView addSubview:carrierImage];
    
    self.carrierLabel = [self getLabelWithFont:17 textAlignment:NSTextAlignmentLeft];
    [self.firstView addSubview:self.carrierLabel];
    
    self.timeLabel = [self getLabelWithFont:14 textAlignment:NSTextAlignmentCenter];
    self.timeLabel.textColor = [UIColor lightGrayColor];
    [self.firstView addSubview:self.timeLabel];
    
    self.stateLabel = [self getLabelWithFont:17 textAlignment:NSTextAlignmentRight];
    [self.firstView addSubview:self.stateLabel];
    
    UIView *secondView = [[UIView alloc]init];
    secondView.backgroundColor = [UIColor whiteColor];
    self.secondView = secondView;
    [self addSubview:secondView];
    
    DCImageAndTextLabel *startLabel = [[DCImageAndTextLabel alloc]init];
    startLabel.imageView.image = IMAGENAME(@"起点");
    self.startLabel = startLabel;
    [self.secondView addSubview:startLabel];
    
    DCImageAndTextLabel *extractLabel = [[DCImageAndTextLabel alloc]init];
    extractLabel.imageView.image = IMAGENAME(@"提现");
    self.extractLabel = extractLabel;
    [self.secondView addSubview:extractLabel];
    
    DCImageAndTextLabel *endLabel = [[DCImageAndTextLabel alloc]init];
    endLabel.imageView.image = IMAGENAME(@"终点");
    self.endLabel = endLabel;
    [self.secondView addSubview:endLabel];
    
    DCImageAndTextLabel *sendLabel = [[DCImageAndTextLabel alloc]init];
    sendLabel.imageView.image = IMAGENAME(@"送");
    self.sendLabel = sendLabel;
    [self.secondView addSubview:sendLabel];
    
    self.carLabel = [[DCImageAndTextLabel alloc]init];
    self.carLabel.imageView.image = IMAGENAME(@"立方体");
    self.carLabel.textLabel.font = FONT(14);
//    self.carLabel.backgroundColor = [UIColor redColor];
    [self.secondView addSubview:self.carLabel];
    
    self.totalNumLabel = [self getLabelWithFont:15 textAlignment:NSTextAlignmentRight];
//    self.totalNumLabel.backgroundColor = [UIColor yellowColor];
    [self.secondView addSubview:self.totalNumLabel];
    
    self.numLabel = [self getLabelWithFont:14 textAlignment:NSTextAlignmentLeft];
//    self.numLabel.backgroundColor = [UIColor cyanColor];
    self.numLabel.textColor = [UIColor lightGrayColor];
    [self.secondView addSubview:self.numLabel];
    
    self.pointImage = [[UIImageView alloc]initWithImage:IMAGENAME(@"箭头")];
    //    self.pointImage.backgroundColor = [UIColor redColor];
    [self addSubview:self.pointImage];
}
-(void)setUpLayoutSubviews
{
    CGFloat kMargin = 10;
    //    CGFloat kHeight = 40;
    self.firstView.frame = CGRectMake(0, kMargin, self.width, kBaseHeight);
    
    self.carrierImage.frame = CGRectMake(10, 3, self.firstView.height - 6, self.firstView.height - 6);
    self.carrierImage.layer.cornerRadius = self.carrierImage.width/2;
    
    self.carrierLabel.frame = CGRectMake(self.carrierImage.right+3, 0, 70*WIDTHSCALE6, self.firstView.height);
    
    self.timeLabel.width = 150*WIDTHSCALE6;
    self.timeLabel.height = self.firstView.height;
    self.timeLabel.y = 0;
    self.timeLabel.centerX = self.firstView.centerX;
    
    self.stateLabel.frame = CGRectMake(self.firstView.width - 70*WIDTHSCALE6, 0, 70*WIDTHSCALE6-3, self.firstView.height);
    
    self.secondView.frame = CGRectMake(0, self.firstView.bottom+1, self.firstView.width, (kBaseHeight-10)*3);
    
    self.startLabel.frame = CGRectMake(20, 0, (self.secondView.width - 30)/3, kBaseHeight-10);
    self.extractLabel.frame = CGRectMake(self.startLabel.right, 0, (self.secondView.width - 30)*2/3, self.startLabel.height);
    self.endLabel.frame = CGRectMake(self.startLabel.x, self.startLabel.bottom, self.startLabel.width, self.startLabel.height);
    self.sendLabel.frame = CGRectMake(self.extractLabel.x, self.endLabel.y, self.extractLabel.width, self.startLabel.height);
    
    self.carLabel.frame = CGRectMake(20, self.sendLabel.bottom, 60*WIDTHSCALE6, self.startLabel.height);
    self.totalNumLabel.frame = CGRectMake(self.carLabel.right, self.carLabel.y, 60*WIDTHSCALE6, self.carLabel.height);
    self.numLabel.frame = CGRectMake(self.totalNumLabel.right, self.carLabel.y, 110*WIDTHSCALE6, self.carLabel.height);
    
    self.pointImage.size = CGSizeMake(20, 20);
    self.pointImage.x = self.width - self.pointImage.width;
    self.pointImage.centerY = self.secondView.centerY;
}


-(UILabel *)getLabelWithFont:(NSInteger)font textAlignment:(NSTextAlignment)textAlignment
{
    UILabel *label = [[UILabel alloc]init];
    label.font = FONT(font);
    label.textAlignment = textAlignment;
    return label;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
